/**
 * 数据服务类
 * APPID:wx1c6a83a3845d8ec3
 */
var auth = require('./auth.js');

const app = getApp(); // 接口配置

const appKey = '1NTAGTE14FEaM3FF';

const appNo = '1655184985';

const BASE_URI = 'https://api.diqihengrun.com'; //基础请求地址

const FILE_URI = 'https://file.diqihengrun.com/image'; //图片等文件请求地址

const GET_WX_OPENID = BASE_URI + '/auth/QR/WxOpenId'; // 获取小程序openId

const IS_LOGIN = BASE_URI + '/auth/Member/IsLogin'; // 是否登录状态

const GET_MEMBER_INFO = BASE_URI + '/app/Member/MemberInfo'; // 获取用户信息

const MEMBER_LOGIN = BASE_URI + '/auth/Member/Token'; // 登录

const MEMBER_REGISTER = BASE_URI + '/auth/Member/Register'; // 注册

const MEMBER_SET_FORGET_PWD = BASE_URI + '/app/Member/SetForgetPwd'; //忘记密码

const SEND_REGISTER_CODE = BASE_URI + '/auth/Sms/RegisterSmsCode'; //发送注册验证码

const SEND_FORGET_PWD_CODE = BASE_URI + '/auth/Sms/PwdSmsCode'; //发送密码相关验证码

const GET_AUTH_CERT = BASE_URI + '/app/Banner/ShouQuanShu'; //获取授权证书

const GET_SHI_MING_XIE_YI = BASE_URI + '/app/App/ShiMingXieYi'; //实名认证协议

const GET_XIA_DAN_XIE_YI = BASE_URI + '/app/App/XiaDanXieYi'; //下单协议

const GET_FRESH_CLASSROOM = BASE_URI + '/app/Banner/FreshClassRoom'; //新手用户指南

const GET_AGENT_CLASSROOM = BASE_URI + '/app/Banner/AgentClassRoom'; //新手代理指南

const GET_SHARE_BANNER = BASE_URI + '/app/Banner/ShareBanner'; //分享Banner

const GET_INVITE_IMG = BASE_URI + '/app/App/FindInviteImg'; //获取邀请伙伴的图片

const GET_ALL_TYPE = BASE_URI + '/app/Article/AllType'; //获取全部问题类型

const GET_TYPE_QUESTION_PAGE = BASE_URI + '/app/Article/TypeQuestionPage'; //类型问题分页

const GET_ALL_FRESH_CLASSROOM = BASE_URI + '/app/Article/AllFreshClassRoom'; //获取全部新手教程

const GET_FRESH_CLASSROOM_DETAIL =
  BASE_URI + '/app/Article/FreshClassRoomDetail'; //新手教程详情

const ADD_CARD = BASE_URI + '/app/Bank/AddCard'; // 新增银行卡

const EDIT_CARD = BASE_URI + '/app/Bank/EditCard'; // 修改银行卡

const GET_MY_BANK_CARD = BASE_URI + '/app/Bank/MyBankCard'; // 获取我的某张银行卡

const GET_MY_ALL_BANK_CARD = BASE_URI + '/app/Bank/MyAllBankCard'; // 我的全部银行卡

const DELETE_BANK_CARD = BASE_URI + '/app/Bank/Del'; //删除银行卡

const GET_ALL_BANK_CARD = BASE_URI + '/app/Bank/AllBank'; // 获取全部银行

const GET_ADDRESS_LIST = BASE_URI + '/app/Address/FindAddressPage'; // 获取地址列表

const ADD_ADDRESS = BASE_URI + '/app/Address/AddAddress'; // 新增地址

const GET_ADDRESS_DATA = BASE_URI + '/app/Address/FindAddress'; // 获取地址

const GET_PROVINCE_DATA = BASE_URI + '/app/Address/FindProvince'; // 获取省份

const GET_CITY_DATA = BASE_URI + '/app/Address/FindCity'; // 获取城市

const GET_REGION_DATA = BASE_URI + '/app/Address/FindRegion'; // 获取地区

const DEL_ADDRESS = BASE_URI + '/app/Address/DelAddress'; // 删除地址

const EDIT_ADDRESS = BASE_URI + '/app/Address/EditAddress'; // 修改地址

const SET_DEFAULT_ADDRESS = BASE_URI + '/app/Address/SetDefaultAddress'; // 设置默认地址

const GET_DEFAULT_ADDRESS = BASE_URI + '/app/Address/FindDefaultAddress'; // 获取默认地址

const GET_HOME_BI = BASE_URI + '/app/BI/HomeBI'; // 获取首页统计

const GET_BANNER_BANNER = BASE_URI + '/app/Banner/Banner'; //  Banner图片集合

const GET_HOT_ACTIVE_BANNER = BASE_URI + '/app/Banner/HotActiveBanner'; //  热门活动Banner

const GET_INVITE_USER = BASE_URI + '/app/Banner/InviteUser'; // 邀请好友图

const GET_WX_QRCODE = BASE_URI + '/app/QR/WxQrCode'; // 获取小程序码

const GET_PRODUCT_PAGE = BASE_URI + '/app/Product/ProductPage'; // 获取产品分页

const GET_PRODUCT_TYPE = BASE_URI + '/app/Product/FindType'; // 获取产品类型

const GET_PRODUCT_DETAIL = BASE_URI + '/app/Product/Product'; // 获取产品详情

const WX_PAY = BASE_URI + '/app/Pay/WxPay'; // 微信支付

const GET_TRADE_PAGE = BASE_URI + '/app/Trade/MyTradePage'; // 交易分页

const TRADE_CANCEL = BASE_URI + '/app/Trade/CannelTrade'; // 取消交易

const ADD_ORDER = BASE_URI + '/app/Trade/AddOrder'; // 下单

const GET_USER_AGREEMENT = BASE_URI + '/app/App/UserAgreement'; // 获取用户协议

const GET_PRIVACY_POLICY = BASE_URI + '/app/App/PrivacyPolicy'; // 获取隐私政策

const GET_MY_TERM = BASE_URI + '/app/Term/MyTerm'; // 获取我的机具

const GET_CHILD_TERM = BASE_URI + '/app/Term/ChildTerm'; // 获取伙伴机具

const GET_MY_STOCK_TERM_TERM = BASE_URI + '/app/Term/MyStockTerm'; // 获取我的库存

const GET_TERM_TYPE = BASE_URI + '/app/Term/TermType'; // 获取全部机具类型

const GET_MY_STOCK_TERM_SO = BASE_URI + '/app/Term/MyStockTermSo'; // 库存列表（区间搜索）

const DOWN_TERM = BASE_URI + '/app/Term/DownTerm'; // 下拨机具

const AUTHENTICATION = BASE_URI + '/app/Member/ShiMing'; // 实名

const GET_MY_PARENT = BASE_URI + '/app/Member/MyParent'; // 我的上级

const GET_MY_T_PARENT = BASE_URI + '/app/Member/MyTParent'; // 我的盟主

const GET_DOWN_RECORD_PAGE = BASE_URI + '/app/Term/DownRecordPage'; // 下拨记录

const GET_TERM_PAGE = BASE_URI + '/app/Term/FindTermPage'; // 我的机具分页

const GET_NOTICE = BASE_URI + '/app/App/Notice'; // 公告

const GET_SUMMARY_BI = BASE_URI + '/app/BI/SummaryBI'; // 日、月，总统计

const GET_QUESTION = BASE_URI + '/app/App/FindQuestion'; // 常见问题

const GET_MY_NEXT_LEVEL = BASE_URI + '/app/Member/MyNextLevel'; // 我的成长值

const SEND_BIND_BANK_SMS_CODE = BASE_URI + '/auth/Sms/BankSmsCode'; // 发送绑银行卡验证码

const GET_MY_ASSETS = BASE_URI + '/app/Member/MyAssets'; // 我的资产-我的钱包

const GET_MY_TEAM_DATA = BASE_URI + '/app/Member/MyTeam'; // 我的团队(数量统计)

const POST_WITHDRAW = BASE_URI + '/app/WithDraw/Withdraw'; // 提现

const GET_WITHDRAW_PAGE = BASE_URI + '/app/WithDraw/WithdrawPage'; // 获取提现记录

const GET_APP_NOTICE = BASE_URI + '/app/App/Notice'; // 获取公告

const GET_MY_BI = BASE_URI + '/app/BI/MyBI'; // 个人统计

const GET_MY_DATA = BASE_URI + '/app/Member/MyData'; // 数据分析

const GET_MY_INTEGRAL_FLOW_PAGE = BASE_URI + '/app/Flow/MyIntegralFlowPage'; // 我的财富值流水分页

const GET_MY_TRANSFER_PAGE = BASE_URI + '/app/Integral/FindMyTransferPage'; // 积分转赠记录

const GET_MY_USER = BASE_URI + '/app/Member/MyUser'; //我的客户

const GET_MY_PARTNER_SUMMARY = BASE_URI + '/app/Member/SummaryMyPartner'; //我的伙伴统计

const GET_MY_PARTNER = BASE_URI + '/app/Member/MyPartner'; //我的伙伴

const GET_MY_USER_SUMMARY = BASE_URI + '/app/Member/SummaryMyUser'; //我的客户统计

const GET_SUMMARY_TRANS_AMOUNT = BASE_URI + '/app/Member/SummaryTransAmount'; //业绩统计-交易金额

const GET_SUMMARY_AGENT = BASE_URI + '/app/Member/SummaryAgent'; // 业绩统计-伙伴

const GET_MY_TRANSFER_INTEGRAL = BASE_URI + '/app/Integral/TransferIntegral'; //转赠积分

const GET_MY_MERCHANT = BASE_URI + '/app/Member/MyMerchant'; //我的商户

const GET_MY_AGENT = BASE_URI + '/app/Member/MyAgent'; //我的富友

const GET_SY = BASE_URI + '/app/Member/GetSy'; // 用户收益

const GET_DAY_USER = BASE_URI + '/app/Member/GetDayUser'; // 今日推广人数

const SYS_ALL_BONUS = BASE_URI + '/app/Bonus/SysAllBonus'; //  系统累计分红

const GET_MY_SUMMARY = BASE_URI + '/app/Transaction/MySummary'; // 统计

const SET_NICK_NAME = BASE_URI + '/app/Member/SetNickName'; // 设置昵称

const IS_OPEN_TASK = BASE_URI + '/app/Task/IsOpen'; // 是否开启任务

const SIGN_IN = BASE_URI + '/app/Task/SignIn'; // 签到

const FIND_DAY_TASK = BASE_URI + '/app/Task/FindDayTask'; // 获取每日任务

const FIND_GROUP_UP_TASK = BASE_URI + '/app/Task/FindGroupUpTask'; // 获取成长任务

const FIND_CASH_TASK = BASE_URI + '/app/Task/FindCashTask'; // 获取现金任务

const RECEIVE_CASH = BASE_URI + '/app/Task/ReceiveCash'; // 领取今日现金奖励

const RECEIVE_WEEK_CASH = BASE_URI + '/app/Task/ReceiveWeekCash'; // 领取周现金奖励

const RECEIVE_MONTH_CASH = BASE_URI + '/app/Task/ReceiveMonthCash'; // 领取月现金奖励

const RECEIVE_NOTICE = BASE_URI + '/app/Task/ReceiveNotice'; // 领取通知奖励

const RECEIVE_AUTH = BASE_URI + '/app/Task/ReceiveAuth'; // 领取实名奖励

const GET_PRODUCT_LIST = BASE_URI + '/app/Product/ProductPage'; //  产品分页

const GET_PRODUCT_FIND_TYPE = BASE_URI + '/app/Product/FindType'; // 产品类型

const RECEIVE_ADD_USER = BASE_URI + '/app/Task/ReceiveAddUser'; //领取推荐直签奖励

const RECEIVE_ACTIVE_TERM = BASE_URI + '/app/Task/ReceiveActiveTerm'; //领取每日激活奖励

const APPLY_LEVEL = BASE_URI + '/app/Bonus/ApplyLevel'; //  申请加入星海联盟club

const TEAM_RANK = BASE_URI + '/app/Member/TeamPaiHangBang'; //  团队排行榜

const SYS_RANK = BASE_URI + '/app/Member/PaiHangBang'; //  系统排行榜

const MY_BUY_PAGE = BASE_URI + '/app/Member/MyBuyPage'; // 购机返现分页

const GET_PROFIT_FLOW = BASE_URI + '/app/Member/ProfitFlow'; // 用户收益流水

const GET_SUMMARY_PROFIT_FLOW = BASE_URI + '/app/Member/SummaryProfitFlow'; // 统计收益流水

const GET_CHIRLD_TRANS_AMOUNT_FLOW =
  BASE_URI + '/app/Member/ChirldTransAmountFlow'; // 业绩统计-交易明细分页

const POST_EXCHANGE = BASE_URI + '/app/Trade/Exchange'; // 兑换

const POST_EXCHANGE_MONEY = BASE_URI + '/app/Trade/ExchangeMoney'; // 兑换现金

const GET_EXCHANGE_MONEY_PAGE = BASE_URI + '/app/Integral/MyCashExchangePage'; // 兑换现金记录

const TRANSFER_INTEGRAL = BASE_URI + '/app/Integral/TransferIntegral'; // 兑换现金

const BACK_INTEGRAL = BASE_URI + '/app/Integral/BackIntegral'; //  转赠撤回

const SEND_MY_SMS_CODE = BASE_URI + '/app/Sms/MySmsCode'; // 发送个人验证码

const FIND_MY_TRANSFER_PAGE = BASE_URI + '/app/Integral/FindMyTransferPage'; //  积分转赠-撤回记录

const GET_MY_SHARE = BASE_URI + '/app/Member/MySharePage'; // 分润收益分页

const GET_MY_BACK = BASE_URI + '/app/Member/MyBackPage'; // 达标返现分页

const GET_MEMBER_CHIRLD = BASE_URI + '/app/Member/Chirld'; // 我的伙伴（全部直推用户）

const GET_FIND_TERM_PAGE = BASE_URI + '/app/Term/FindTermPage'; // 机具分页

const GET_BRAND = BASE_URI + '/app/Term/FindBrand'; // 获取品牌

const GET_MY_STOCK_TERM_LIST = BASE_URI + '/app/Term/MyStockTermList'; // 库存列表（未划拨的）

const TRANSFER_TERM = BASE_URI + '/app/Term/TransferTerm'; // 划拨机具

const GET_MY_MERCHANT_PAGE = BASE_URI + '/app/Member/MyMerchantPage'; // 我的商户分页

const GET_MY_MERCHANT_INFO = BASE_URI + '/app/Member/MyMerchantInfo'; // 我的真实商户分页

const LOAN_REFUND = BASE_URI + '/app/Member/LoanRefund'; //  还款记录

const GET_TUI_GUANG = BASE_URI + '/app/Banner/TuiGuang'; // 推广图

const CHUANG_YE_JIN = BASE_URI + '/app/Banner/ChuangYeJin'; // 创业金

const MEMBER_DAIKUAN = BASE_URI + '/app/Member/DaiKuan'; // 申请贷款

const GET_INTEGRAL_PRODUCT = BASE_URI + '/app/Product/IntegralProduct'; // 获取积分商品

const IS_APPLY_CHECKING = BASE_URI + '/app/Bonus/IsApplyChecking'; //  是否已存在申请

const GET_XIAN_TU = BASE_URI + '/app/Member/XianTu'; //  线图统计

const RESET_MEMBER = BASE_URI + '/app/Member/ResetMember'; // 注销账号

const MY_LOAN_DATA = BASE_URI + '/app/Member/MyLoanData'; // 我的联盟津贴

const GET_MEMBER_LEVEL_SETTING = BASE_URI + '/app/App/GetMemberLevleSetting'; // 获取会员等级配置

const GET_LB_GOODS = BASE_URI + '/app/Goods/LbGoods'; // 礼包商品

const OPEN_MEMBER_LEVEL = BASE_URI + '/app/Member/OpenMemberLevel'; // 开通会员等级

const OPEN_AGENT_LEVEL = BASE_URI + '/app/Member/OpenAgentLevel'; // 开通代理等级

const GET_AGENT_LEVEL_SETTING = BASE_URI + '/app/App/GetAgentLevleSetting'; // 获取代理商等级配置

const GET_MEMBER_ASSETS = BASE_URI + '/app/Member/MemberAssets'; // 用户余额

const GET_MY_TASK = BASE_URI + '/app/Task/MyTask'; // 我的任务

const GIVE_TASK_ONE = BASE_URI + '/app/Task/GiveTaskOne'; // 领取任务1奖励

const GIVE_TASK_TWO = BASE_URI + '/app/Task/GiveTaskTwo'; // 领取任务二奖励

const GIVE_TRANS_PAGE = BASE_URI + '/app/Transaction/TransPage'; // 交易账单

const GIVE_TRANS_DETAIL = BASE_URI + '/app/Transaction/TransDetail'; // 无卡交易详情

const CHECK_ID_CARD = BASE_URI + '/app/Member/CheckIdCard'; // 身份证识别

const GET_HYSM = BASE_URI + '/app/App/Hysm'; // 会员说明

const GET_DLSM = BASE_URI + '/app/App/Dlsm'; // 代理说明

const TRANS_SMS_CODE = BASE_URI + '/app/Transaction/TransSmsCode'; // 发送无卡交易验证码

const TRANS_PAY = BASE_URI + '/app/Transaction/TransPay'; // 确认无卡交易

const GET_CHILD_TRADE = BASE_URI + '/app/Trade/ChildTrade'; // 机器订货

const GET_MY_USER_DETAIL = BASE_URI + '/app/Member/MyUserDetail'; // 客户详情

const IS_CHECK = BASE_URI + '/app/App/IsCheck'; // 客户详情

const GET_PARENT_PHONE = BASE_URI + '/app/Member/ParentPhone'; // 上级号码

const ID_CARD_IMG_NAME = BASE_URI + '/app/App/IdCardImgName'; // 图片描述名称

const GET_APP_VERSION = BASE_URI + "/app/App/AppVersion"; // 获取APP更新信息

/**
 * 服务对象
 */

let service = {
  // 获取基础请求地址
  getBaseUrl: function () {
    return BASE_URI;
  },

  // 获取图片等文件请求地址
  getFileUrl: function () {
    return FILE_URI;
  },

  // 获取小程序openId
  getOpenid(args, onSuccess, onError) {
    http.get(GET_WX_OPENID, args, onSuccess, onError);
  },

  // 是否登录状态
  isLogin(args, onSuccess, onError) {
    http.get(IS_LOGIN, args, onSuccess, onError);
  },

  // 获取用户信息
  getMyInfo(args, onSuccess, onError) {
    http.get(GET_MEMBER_INFO, args, onSuccess, onError);
  },

  //登录
  memberLogin(args, onSuccess, onError) {
    http.get(MEMBER_LOGIN, args, onSuccess, onError);
  },

  //忘记密码
  memberSetForgetPwd(args, onSuccess, onError) {
    http.post(MEMBER_SET_FORGET_PWD, args, onSuccess, onError);
  },

  //发送注册验证码
  sendRegisterSmsCode(args, onSuccess, onError) {
    http.post(SEND_REGISTER_CODE, args, onSuccess, onError);
  },

  // 注册
  memberRegister(args, onSuccess, onError) {
    http.post(MEMBER_REGISTER, args, onSuccess, onError);
  },

  //发送忘记密码验证码
  sendForgetPwdSmsCode(args, onSuccess, onError) {
    http.post(SEND_FORGET_PWD_CODE, args, onSuccess, onError);
  },

  // 获取授权书
  getAuthCert(args, onSuccess, onError) {
    http.get(GET_AUTH_CERT, args, onSuccess, onError);
  },

  // 实名认证协议
  getShiMingXieYi(args, onSuccess, onError) {
    http.get(GET_SHI_MING_XIE_YI, args, onSuccess, onError);
  },

  //下单协议
  getXiaDanXieYi(args, onSuccess, onError) {
    http.get(GET_XIA_DAN_XIE_YI, args, onSuccess, onError);
  },

  //新手用户指南
  getFreshClassRoom(args, onSuccess, onError) {
    http.get(GET_FRESH_CLASSROOM, args, onSuccess, onError);
  },

  //新手代理指南
  getAgentClassRoom(args, onSuccess, onError) {
    http.get(GET_AGENT_CLASSROOM, args, onSuccess, onError);
  },

  //分享Banner
  getShareBanner(args, onSuccess, onError) {
    http.get(GET_SHARE_BANNER, args, onSuccess, onError);
  },

  //获取邀请伙伴的图片
  getInviteImg(args, onSuccess, onError) {
    http.get(GET_INVITE_IMG, args, onSuccess, onError);
  },

  //获取全部问题类型
  getAllType(args, onSuccess, onError) {
    http.get(GET_ALL_TYPE, args, onSuccess, onError);
  },

  //类型问题分页
  getTypeQuestionPage(args, onSuccess, onError) {
    http.get(GET_TYPE_QUESTION_PAGE, args, onSuccess, onError);
  },

  //获取全部新手教程
  getAllFreshClassRoom(args, onSuccess, onError) {
    http.get(GET_ALL_FRESH_CLASSROOM, args, onSuccess, onError);
  },

  //新手教程详情
  getFreshClassRoomDetail(args, onSuccess, onError) {
    http.get(GET_FRESH_CLASSROOM_DETAIL, args, onSuccess, onError);
  },

  // 增加银行卡
  addCard(args, onSuccess, onError) {
    http.post(ADD_CARD, args, onSuccess, onError);
  },

  // 修改银行卡
  editCard(args, onSuccess, onError) {
    http.post(EDIT_CARD, args, onSuccess, onError);
  },

  // 我的某张银行卡
  getMyBankCard(args, onSuccess, onError) {
    http.get(GET_MY_BANK_CARD, args, onSuccess, onError);
  },

  // 我的全部银行卡
  getMyAllBankCard(args, onSuccess, onError) {
    http.get(GET_MY_ALL_BANK_CARD, args, onSuccess, onError);
  },

  // 删除银行卡
  deleteBankCard(args, onSuccess, onError) {
    http.post(DELETE_BANK_CARD, args, onSuccess, onError);
  },

  // 获取全部银行
  getAllBankCard(args, onSuccess, onError) {
    http.get(GET_ALL_BANK_CARD, args, onSuccess, onError);
  },

  // 获取地址
  getAddressList(args, onSuccess, onError) {
    http.get(GET_ADDRESS_LIST, args, onSuccess, onError);
  },

  // 新增地址
  addAddress(args, onSuccess, onError) {
    http.post(ADD_ADDRESS, args, onSuccess, onError);
  },

  // 修改地址
  editOrderAddress(args, onSuccess, onError) {
    http.post(EDIT_ORDER_ADDRESS, args, onSuccess, onError);
  },

  // 获取地址
  getAddressData(args, onSuccess, onError) {
    http.get(GET_ADDRESS_DATA, args, onSuccess, onError);
  },

  // 获取省份
  getProvinceData(args, onSuccess, onError) {
    http.get(GET_PROVINCE_DATA, args, onSuccess, onError);
  },

  // 获取城市
  getCityData(args, onSuccess, onError) {
    http.get(GET_CITY_DATA, args, onSuccess, onError);
  },

  // 获取区县
  getRegionData(args, onSuccess, onError) {
    http.get(GET_REGION_DATA, args, onSuccess, onError);
  },

  // 删除地址
  deleteAddress(args, onSuccess, onError) {
    http.post(DEL_ADDRESS, args, onSuccess, onError);
  },

  // 修改地址
  editAddress(args, onSuccess, onError) {
    http.post(EDIT_ADDRESS, args, onSuccess, onError);
  },

  // 设置默认地址
  setDefaultAddress(args, onSuccess, onError) {
    http.post(SET_DEFAULT_ADDRESS, args, onSuccess, onError);
  },

  // 获取默认地址
  getDefaultAddress(args, onSuccess, onError) {
    http.get(GET_DEFAULT_ADDRESS, args, onSuccess, onError);
  },

  // 获取首页统计
  getHomeBI(args, onSuccess, onError) {
    http.get(GET_HOME_BI, args, onSuccess, onError);
  },

  // Banner图片集合
  getBanner(args, onSuccess, onError) {
    http.get(GET_BANNER_BANNER, args, onSuccess, onError);
  },

  //  热门活动Banner
  getHotActiveBanner(args, onSuccess, onError) {
    http.get(GET_HOT_ACTIVE_BANNER, args, onSuccess, onError);
  },

  // 邀请好友图
  getInviteUser(args, onSuccess, onError) {
    http.get(GET_INVITE_USER, args, onSuccess, onError);
  },

  // 获取小程序码
  getWxQrCode(args, onSuccess, onError) {
    http.get(GET_WX_QRCODE, args, onSuccess, onError);
  },

  // 获取产品分页
  getProductPage(args, onSuccess, onError) {
    http.get(GET_PRODUCT_PAGE, args, onSuccess, onError);
  },

  // 获取产品类型
  getProductType(args, onSuccess, onError) {
    http.get(GET_PRODUCT_TYPE, args, onSuccess, onError);
  },

  // 获取产品详情
  getProductDetail(args, onSuccess, onError) {
    http.get(GET_PRODUCT_DETAIL, args, onSuccess, onError);
  },

  // 微信支付
  wxPay(args, onSuccess, onError) {
    http.post(WX_PAY, args, onSuccess, onError);
  },

  // 交易分页
  getTradePage(args, onSuccess, onError) {
    http.get(GET_TRADE_PAGE, args, onSuccess, onError);
  },

  // 取消交易
  tradeCancel(args, onSuccess, onError) {
    http.post(TRADE_CANCEL, args, onSuccess, onError);
  },

  // 下单
  addOrder(args, onSuccess, onError) {
    http.post(ADD_ORDER, args, onSuccess, onError);
  },

  // 获取用户协议
  getUserAgreement(args, onSuccess, onError) {
    http.get(GET_USER_AGREEMENT, args, onSuccess, onError);
  },

  // 获取隐私政策
  getPrivacyPolicy(args, onSuccess, onError) {
    http.get(GET_PRIVACY_POLICY, args, onSuccess, onError);
  },

  // 获取我的机具
  getMyTerm(args, onSuccess, onError) {
    http.get(GET_MY_TERM, args, onSuccess, onError);
  },

  // 获取伙伴机具
  getChildTerm(args, onSuccess, onError) {
    http.get(GET_CHILD_TERM, args, onSuccess, onError);
  },

  // 获取我的库存
  getMyStockTerm(args, onSuccess, onError) {
    http.get(GET_MY_STOCK_TERM_TERM, args, onSuccess, onError);
  },

  // 获取全部机具类型
  getTermType(args, onSuccess, onError) {
    http.get(GET_TERM_TYPE, args, onSuccess, onError);
  },

  // 库存列表（区间搜索）
  getMyStockTermSo(args, onSuccess, onError) {
    http.get(GET_MY_STOCK_TERM_SO, args, onSuccess, onError);
  },

  // 下拨机具
  downTerm(args, onSuccess, onError) {
    http.post(DOWN_TERM, args, onSuccess, onError);
  },

  //实名
  authentication(args, onSuccess, onError) {
    http.post(AUTHENTICATION, args, onSuccess, onError);
  },

  // 我的上级
  getMyParent(args, onSuccess, onError) {
    http.get(GET_MY_PARENT, args, onSuccess, onError);
  },

  // 我的盟主
  getMyTParent(args, onSuccess, onError) {
    http.get(GET_MY_T_PARENT, args, onSuccess, onError);
  },

  // 下拨记录
  getDownRecordPage(args, onSuccess, onError) {
    http.post(GET_DOWN_RECORD_PAGE, args, onSuccess, onError);
  },

  // 我的机具分页
  getTermPage(args, onSuccess, onError) {
    http.get(GET_TERM_PAGE, args, onSuccess, onError);
  },

  // 获取公告
  getNotice(args, onSuccess, onError) {
    http.get(GET_NOTICE, args, onSuccess, onError);
  },

  // 日、月，总统计
  getSummaryBI(args, onSuccess, onError) {
    http.get(GET_SUMMARY_BI, args, onSuccess, onError);
  },

  // 常见问题
  getQuestion(args, onSuccess, onError) {
    http.get(GET_QUESTION, args, onSuccess, onError);
  },

  // 我的成长值
  getMyNextLevel(args, onSuccess, onError) {
    http.get(GET_MY_NEXT_LEVEL, args, onSuccess, onError);
  },

  // 发送绑银行卡验证码
  sendBindBankSmsCode(args, onSuccess, onError) {
    http.post(SEND_BIND_BANK_SMS_CODE, args, onSuccess, onError);
  },

  // 我的资产-我的钱包
  getMyAssets(args, onSuccess, onError) {
    http.get(GET_MY_ASSETS, args, onSuccess, onError);
  },

  // 我的团队(数量统计)
  getMyTeamData(args, onSuccess, onError) {
    http.get(GET_MY_TEAM_DATA, args, onSuccess, onError);
  },

  // 提现
  withdrew(args, onSuccess, onError) {
    http.post(POST_WITHDRAW, args, onSuccess, onError);
  },

  // 获取提现记录
  getWithdrawPage(args, onSuccess, onError) {
    http.get(GET_WITHDRAW_PAGE, args, onSuccess, onError);
  },

  // 获取公告
  getAppNotice(args, onSuccess, onError) {
    http.get(GET_APP_NOTICE, args, onSuccess, onError);
  },

  // 个人统计
  getMyBI(args, onSuccess, onError) {
    http.get(GET_MY_BI, args, onSuccess, onError);
  },

  // 数据分析
  getMyData(args, onSuccess, onError) {
    http.get(GET_MY_DATA, args, onSuccess, onError);
  },

  // 我的财富值流水分页
  getMyIntegralFlowPage(args, onSuccess, onError) {
    http.get(GET_MY_INTEGRAL_FLOW_PAGE, args, onSuccess, onError);
  },

  // 积分转赠记录
  getMyTransferPage(args, onSuccess, onError) {
    http.get(GET_MY_TRANSFER_PAGE, args, onSuccess, onError);
  },

  //我的伙伴
  getMyPartner(args, onSuccess, onError) {
    http.get(GET_MY_PARTNER, args, onSuccess, onError);
  },

  //我的伙伴统计
  getMyPartnerSummary(args, onSuccess, onError) {
    http.get(GET_MY_PARTNER_SUMMARY, args, onSuccess, onError);
  },

  //我的客户
  getMyUser(args, onSuccess, onError) {
    http.get(GET_MY_USER, args, onSuccess, onError);
  },

  //我的客户统计
  getMyUserSummary(args, onSuccess, onError) {
    http.get(GET_MY_USER_SUMMARY, args, onSuccess, onError);
  },

  // 业绩统计-交易金额
  getSummaryTransAmount(args, onSuccess, onError) {
    http.get(GET_SUMMARY_TRANS_AMOUNT, args, onSuccess, onError);
  },

  // 业绩统计-伙伴
  getSummaryAgent(args, onSuccess, onError) {
    http.get(GET_SUMMARY_AGENT, args, onSuccess, onError);
  },

  //转赠积分
  getTransferIntegral(args, onSuccess, onError) {
    http.get(GET_MY_TRANSFER_INTEGRAL, args, onSuccess, onError);
  },

  //我的商户
  getMyMerchant(args, onSuccess, onError) {
    http.get(GET_MY_MERCHANT, args, onSuccess, onError);
  },

  //我的富友
  getMyAgent(args, onSuccess, onError) {
    http.get(GET_MY_AGENT, args, onSuccess, onError);
  },

  // 用户收益
  getUserProfit(args, onSuccess, onError) {
    http.get(GET_SY, args, onSuccess, onError);
  },

  // 今日推广人数
  getDayUser(args, onSuccess, onError) {
    http.get(GET_DAY_USER, args, onSuccess, onError);
  },

  //  系统累计分红
  sysAllBonus(args, onSuccess, onError) {
    http.get(SYS_ALL_BONUS, args, onSuccess, onError);
  },

  // 统计
  getMySummary(args, onSuccess, onError) {
    http.get(GET_MY_SUMMARY, args, onSuccess, onError);
  },

  // 设置昵称
  setNickName(args, onSuccess, onError) {
    http.post(SET_NICK_NAME, args, onSuccess, onError);
  },

  // 是否开启任务
  isOpenTask(args, onSuccess, onError) {
    http.get(IS_OPEN_TASK, args, onSuccess, onError);
  },

  // 签到
  signIn(args, onSuccess, onError) {
    http.post(SIGN_IN, args, onSuccess, onError);
  },

  // 获取每日任务
  findDayTask(args, onSuccess, onError) {
    http.get(FIND_DAY_TASK, args, onSuccess, onError);
  },

  // 获取成长任务
  findGroupUpTask(args, onSuccess, onError) {
    http.get(FIND_GROUP_UP_TASK, args, onSuccess, onError);
  },

  // 获取现金任务
  findCashTask(args, onSuccess, onError) {
    http.get(FIND_CASH_TASK, args, onSuccess, onError);
  },

  // 领取今日现金奖励
  receiveCash(args, onSuccess, onError) {
    http.post(RECEIVE_CASH, args, onSuccess, onError);
  },

  // 领取周现金奖励
  receiveWeekCash(args, onSuccess, onError) {
    http.post(RECEIVE_WEEK_CASH, args, onSuccess, onError);
  },

  // 领取月现金奖励
  receiveMonthCash(args, onSuccess, onError) {
    http.post(RECEIVE_MONTH_CASH, args, onSuccess, onError);
  },

  // 领取通知奖励
  receiveNotice(args, onSuccess, onError) {
    http.post(RECEIVE_NOTICE, args, onSuccess, onError);
  },

  // 领取实名奖励
  receiveAuth(args, onSuccess, onError) {
    http.post(RECEIVE_AUTH, args, onSuccess, onError);
  },

  //  产品分页
  getProductList(args, onSuccess, onError) {
    http.get(GET_PRODUCT_LIST, args, onSuccess, onError);
  },

  // 产品类型
  getProductFindType(args, onSuccess, onError) {
    http.get(GET_PRODUCT_FIND_TYPE, args, onSuccess, onError);
  },

  // 领取推荐直签奖励
  receiveAddUser(args, onSuccess, onError) {
    http.post(RECEIVE_ADD_USER, args, onSuccess, onError);
  },

  // 领取每日激活奖励
  receiveActiveTerm(args, onSuccess, onError) {
    http.post(RECEIVE_ACTIVE_TERM, args, onSuccess, onError);
  },

  // 申请加入星海联盟club
  applyLevel(args, onSuccess, onError) {
    http.post(APPLY_LEVEL, args, onSuccess, onError);
  },

  //  团队排行榜
  teamRank(args, onSuccess, onError) {
    http.get(TEAM_RANK, args, onSuccess, onError);
  },

  // 系统排行榜
  sysRank(args, onSuccess, onError) {
    http.get(SYS_RANK, args, onSuccess, onError);
  },

  // 购机返现分页
  getMyBuyPage(args, onSuccess, onError) {
    http.get(MY_BUY_PAGE, args, onSuccess, onError);
  },

  // 用户收益流水
  getProfitFlow(args, onSuccess, onError) {
    http.get(GET_PROFIT_FLOW, args, onSuccess, onError);
  },

  // 统计收益流水
  getSummaryProfitFlow(args, onSuccess, onError) {
    http.get(GET_SUMMARY_PROFIT_FLOW, args, onSuccess, onError);
  },

  // 业绩统计-交易明细分页
  getChirldTransAmountFlow(args, onSuccess, onError) {
    http.get(GET_CHIRLD_TRANS_AMOUNT_FLOW, args, onSuccess, onError);
  },

  // 兑换
  postExchange(args, onSuccess, onError) {
    http.post(POST_EXCHANGE, args, onSuccess, onError);
  },

  // 兑换现金
  postExchangeMoney(args, onSuccess, onError) {
    http.post(POST_EXCHANGE_MONEY, args, onSuccess, onError);
  },

  // 兑换现金记录
  getMyCashExchangePage(args, onSuccess, onError) {
    http.get(GET_EXCHANGE_MONEY_PAGE, args, onSuccess, onError);
  },

  // 兑换现金
  transferIntegral(args, onSuccess, onError) {
    http.post(TRANSFER_INTEGRAL, args, onSuccess, onError);
  },

  //  转赠撤回
  backIntegral(args, onSuccess, onError) {
    http.post(BACK_INTEGRAL, args, onSuccess, onError);
  },

  //  发送个人验证码
  sendMySmsCode(args, onSuccess, onError) {
    http.post(SEND_MY_SMS_CODE, args, onSuccess, onError);
  },

  //  积分转赠-撤回记录
  getTransferPage(args, onSuccess, onError) {
    http.get(FIND_MY_TRANSFER_PAGE, args, onSuccess, onError);
  },

  // 分润收益分页
  getMyShareSharePage(args, onSuccess, onError) {
    http.get(GET_MY_SHARE, args, onSuccess, onError);
  },

  // 达标返现分页
  getMyBackPage(args, onSuccess, onError) {
    http.get(GET_MY_BACK, args, onSuccess, onError);
  },

  // 我的伙伴（全部直推用户）
  getMemberChirld(args, onSuccess, onError) {
    http.get(GET_MEMBER_CHIRLD, args, onSuccess, onError);
  },

  // 机具分页
  getFindTermPage(args, onSuccess, onError) {
    http.get(GET_FIND_TERM_PAGE, args, onSuccess, onError);
  },

  // 获取品牌
  getBrand(args, onSuccess, onError) {
    http.get(GET_BRAND, args, onSuccess, onError);
  },

  // 库存列表（未划拨的）
  getMyStockTermList(args, onSuccess, onError) {
    http.get(GET_MY_STOCK_TERM_LIST, args, onSuccess, onError);
  },

  // 划拨机具
  transferTerm(args, onSuccess, onError) {
    http.post(TRANSFER_TERM, args, onSuccess, onError);
  },

  // 我的商户分页
  getMyMerchantPage(args, onSuccess, onError) {
    http.get(GET_MY_MERCHANT_PAGE, args, onSuccess, onError);
  },

  // 我的真实商户分页
  getMyMerchantInfo(args, onSuccess, onError) {
    http.get(GET_MY_MERCHANT_INFO, args, onSuccess, onError);
  },

  //  还款记录
  loanRefund(args, onSuccess, onError) {
    http.get(LOAN_REFUND, args, onSuccess, onError);
  },

  // 推广图
  getTuiGuang(args, onSuccess, onError) {
    http.get(GET_TUI_GUANG, args, onSuccess, onError);
  },

  // 创业金
  getChuangYeJin(args, onSuccess, onError) {
    http.get(CHUANG_YE_JIN, args, onSuccess, onError);
  },

  // 申请贷款
  postDaiKuan(args, onSuccess, onError) {
    http.post(MEMBER_DAIKUAN, args, onSuccess, onError);
  },

  // 获取积分商品
  getIntegralProduct(args, onSuccess, onError) {
    http.get(GET_INTEGRAL_PRODUCT, args, onSuccess, onError);
  },

  //  是否已存在申请
  isApplyChecking(args, onSuccess, onError) {
    http.get(IS_APPLY_CHECKING, args, onSuccess, onError);
  },

  //  线图统计
  getXianTu(args, onSuccess, onError) {
    http.get(GET_XIAN_TU, args, onSuccess, onError);
  },

  // 注销账号
  resetMember(args, onSuccess, onError) {
    http.post(RESET_MEMBER, args, onSuccess, onError);
  },

  // 我的联盟津贴
  myLoanData(args, onSuccess, onError) {
    http.get(MY_LOAN_DATA, args, onSuccess, onError);
  },

  // 获取会员等级配置
  getMemberLevelSetting(args, onSuccess, onError) {
    http.get(GET_MEMBER_LEVEL_SETTING, args, onSuccess, onError);
  },

  // 礼包商品
  getLbGoods(args, onSuccess, onError) {
    http.get(GET_LB_GOODS, args, onSuccess, onError);
  },

  // 开通会员等级
  openMemberLevel(args, onSuccess, onError) {
    http.post(OPEN_MEMBER_LEVEL, args, onSuccess, onError);
  },

  // 开通代理等级
  openAgentLevel(args, onSuccess, onError) {
    http.post(OPEN_AGENT_LEVEL, args, onSuccess, onError);
  },

  //  获取代理商等级配置
  getAgentLevelSetting(args, onSuccess, onError) {
    http.get(GET_AGENT_LEVEL_SETTING, args, onSuccess, onError);
  },

  // 用户余额
  getMemberAssets(args, onSuccess, onError) {
    http.get(GET_MEMBER_ASSETS, args, onSuccess, onError);
  },

  // 我的任务
  getMyTask(args, onSuccess, onError) {
    http.get(GET_MY_TASK, args, onSuccess, onError);
  },

  // 领取任务1奖励
  giveTaskOne(args, onSuccess, onError) {
    http.get(GIVE_TASK_ONE, args, onSuccess, onError);
  },

  // 领取任务二奖励
  giveTaskTwo(args, onSuccess, onError) {
    http.get(GIVE_TASK_TWO, args, onSuccess, onError);
  },

  // 交易账单
  giveTransPage(args, onSuccess, onError) {
    http.get(GIVE_TRANS_PAGE, args, onSuccess, onError);
  },

  // 无卡交易详情
  giveTransDetail(args, onSuccess, onError) {
    http.get(GIVE_TRANS_DETAIL, args, onSuccess, onError);
  },

  // 身份证识别
  CheckIdCard(args, onSuccess, onError) {
    http.post(CHECK_ID_CARD, args, onSuccess, onError);
  },

  // 会员说明
  getHysm(args, onSuccess, onError) {
    http.get(GET_HYSM, args, onSuccess, onError);
  },

  // 代理说明
  getDlsm(args, onSuccess, onError) {
    http.get(GET_DLSM, args, onSuccess, onError);
  },

  // 发送无卡交易验证码
  sendTransSmsCode(args, onSuccess, onError) {
    http.post(TRANS_SMS_CODE, args, onSuccess, onError);
  },

  // 确认无卡交易
  transPay(args, onSuccess, onError) {
    http.post(TRANS_PAY, args, onSuccess, onError);
  },

  // 机器订货
  getChildTrade(args, onSuccess, onError) {
    http.get(GET_CHILD_TRADE, args, onSuccess, onError);
  },

  // 客户详情
  getMyUserDetail(args, onSuccess, onError) {
    http.get(GET_MY_USER_DETAIL, args, onSuccess, onError);
  },
  
  //登陆前检查
  isCheck(args, onSuccess, onError) {
    http.get(IS_CHECK, args, onSuccess, onError);
  },
  
  //上级号码
  getParentPhone(args, onSuccess, onError) {
    http.get(GET_PARENT_PHONE, args, onSuccess, onError);
  },
  
  //图片描述名称
  getIdCardImgName(args, onSuccess, onError) {
    http.get(ID_CARD_IMG_NAME, args, onSuccess, onError);
  },
  
  //获取APP更新信息
  appVersionCheck(args, onSuccess, onError) {
    http.get(GET_APP_VERSION, args, onSuccess, onError);
  },
};
export default service;
/**
 * http请求封装
 */
let http = {
  /**
   * 发送GET请求
   * @param {String} api 接口URL
   * @param {Object} args 参数
   * @param {Function} onSuccess 成功回调函数
   * @param {Function} onError 失败回调函数
   */
  get: function (api, args, onSuccess, onError) {
    this.call(api, args, 'GET', onSuccess, onError);
  },

  /**
   * 发送POST请求
   * @param {String} api
   * @param {Object} args
   * @param {Function} onSuccess
   * @param {Function} onError
   */
  post: function (api, args, onSuccess, onError) {
    this.call(api, args, 'POST', onSuccess, onError);
  },

  /**
   * 发送PUT请求
   * @param {String} api
   * @param {Object} args
   * @param {Function} onSuccess
   * @param {Function} onError
   */
  put: function (api, args, onSuccess, onError) {
    this.call(api, args, 'PUT', onSuccess, onError);
  },

  /**
   * 发送DELETE请求
   * @param {String} api
   * @param {Object} args
   * @param {Function} onSuccess
   * @param {Function} onError
   */
  delete: function (api, args, onSuccess, onError) {
    this.call(api, args, 'DELETE', onSuccess, onError);
  },

  call: function (api, args, method, onSuccess, onError) {
    var token = getWxToken();
	args["isFrom"] = 1;
    args['appNo'] = appNo;
    args['timestamp'] = auth.getTimestamp();
    var sign = auth.sign(appKey, args);
    args['sign'] = sign;

    // console.info("请求接口：" + api)
    // console.info("请求参数：" + JSON.stringify(args))
    // console.info("请求token：" + token)

    uni.request({
      url: api,
      method: method,
      data: args || {},
      dataType: 'json',
      header: {
        'content-type': 'application/json',
        Authorization: token ? 'Bearer ' + token : '',
      },
      success: function (res) {
        // console.info("返回参数：" + JSON.stringify(res))
        if (
          (res.statusCode === 200 && res.data.code === 403) ||
          res.statusCode === 401
        ) {
          uni.removeStorageSync('token');
          uni.reLaunch({
            url: '/pages/login/index',
          });
          return;
        }

        if (res.statusCode === 200 && typeof onSuccess === 'function') {
          onSuccess(res.data);
        } else {
          // uni.showToast({
          //   title: res.data.message || '请求异常,请稍后再试',
          //   icon: 'none',
          //   duration: 3000,
          // });
          if (typeof onError === 'function') {
            onError(res.data);
          }
        }
      },
      fail: function (res) {
        requestFail(res);
        if (typeof onError === 'function') {
          onError(res);
        }
      },
    });
  },
};

function getWxToken() {
  var token = '';
  if (uni.getStorageSync('token')) {
    token = uni.getStorageSync('token');
    return token;
  }
  return token;
}

// 连接失败处理函数
const requestFail = res => {
  if (
    res.errMsg.indexOf('time out') > -1 ||
    res.errMsg.indexOf('timeout') > -1
  ) {
    uni.showToast({
      title: '请求超时,请检查您的网络',
      icon: 'none',
      duration: 3000,
    });
  } else if (res.errMsg.indexOf('connect error') > -1) {
    uni.showToast({
      title: '当前网络不佳,请稍后重试',
      icon: 'none',
      duration: 3000,
    });
  } else {
    // uni.showToast({
    //   title: '请求异常,请稍后再试',
    //   icon: 'none',
    //   duration: 3000,
    // });
  }
};
